In the mathematical field of graph theory, the distance between two vertices in a graph is the number of edges in a shortest path connecting them. This is also known as the geodesic distance [1] because it is the length of the graph geodesic between those two vertices.[2] If there is no path connecting the two vertices, i.e., if they belong to different connected components, then conventionally the distance is defined as infinite.
The vertex set (of an undirected graph) and the distance function form a metric space, if and only if the graph is connected.
A metric defined over a set of points in terms of distances in a graph defined over the set is called a graph metric.
There are a number of other measurements defined in terms of distance:
The eccentricity of a vertex is the greatest geodesic distance between and any other vertex. It can be thought of as how far a node is from the node most distant from it in the graph.
The radius of a graph is the minimum eccentricity of any vertex.
The diameter of a graph is the maximum eccentricity of any vertex in the graph. That is, it is the greatest distance between any pair of vertices. To find the diameter of a graph, first find the shortest path between each pair of vertices. The greatest length of any of these paths is the diameter of the graph.
A central vertex in a graph of radius is one whose eccentricity is —that is, a vertex that achieves the radius.
A peripheral vertex in a graph of diameter is one that is distance from some other vertex—that is, a vertex that achieves the diameter.
A pseudo-peripheral vertex has the property that for any vertex , if is as far away from as possible, then is as far away from as possible. Formally, a vertex u is pseudo-peripheral, if for each vertex v with holds .
Often peripheral sparse matrix algorithms need a starting vertex with a high eccentricity. A peripheral vertex would be perfect, but is often hard to calculate. In most circumstances a pseudo-peripheral vertex can be used. A pseudo-peripheral vertex can easily be found with the following algorithm: